// eslint-disable-next-line
import { UserLayout, BasicLayout, BlankLayout } from '@/layouts'
import {agreement,approval,business,evaluation,manage,defaults,statistical,systemManage,userPower} from '@/core/icons'

const iconRender = (v)=>{
  const render = function render(h){
  return h('svg',
    [
      h('use',{
        attrs:{
          'xlink:href':`#${v}`
        }
      })
    ]
    )
  }
  return {
    name:'iconRender',
    render
  }
}

const RouteView = {
  name: 'RouteView',
  render: h => h('router-view')
}
export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: 'menu.home' },
    redirect: '/business/List',
    children: [
      //审批
      {
        path: '/approval',
        name: 'approval',
        redirect: '/approval/evaluation',
        component: RouteView,
        meta: { title: '新西兰审批',icon:iconRender('icon-dkw_shenhezhong'),permission:['approvalList'] },
        children: [
          {
            path: '/approval/evaluation',
            name: '/approval/evaluation',
            component: () => import('@/views/approval/Evaluation'),
            meta: { title: '项目评估审批' }
          },
          {
            path: '/approval/addLoan',
            name: '/approval/addLoan',
            component: () => import('@/views/approval/AddLoan'),
            meta: { title: 'Top up 审批' }
          },
          {
            path: '/approval/delay',
            name: '/approval/delay',
            component: () => import('@/views/approval/Delay'),
            meta: { title: 'Extension审批' }
          },
        ]
      },
      // 查阅
      {
        path: '/consult',
        name: 'consult',
        redirect: '/consult/evaluation',
        component: RouteView,
        meta: { title: '香港查阅',icon:iconRender('icon-dkw_shenhezhong'),permission:['consultList'] },
        children: [
          {
            path: '/consult/evaluation',
            name: '/consult/evaluation',
            component: () => import('@/views/consult/Evaluation'),
            meta: { title: '项目评估查阅' }
          },
          {
            path: '/consult/addLoan',
            name: '/consult/addLoan',
            component: () => import('@/views/consult/AddLoan'),
            meta: { title: 'Top up 查阅' }
          },
          {
            path: '/consult/delay',
            name: '/consult/delay',
            component: () => import('@/views/consult/Delay'),
            meta: { title: 'Extension查阅' }
          },
          {
            path: '/consult/submit',
            name: '/consult/submit',
            component: () => import('@/views/consult/Submit'),
            meta: { title: '提款资金安排查阅' }
          }
        ]
      },
      // 商机
      {
        path: '/business',
        name: 'business',
        redirect: '/business/List',
        component: RouteView,
        meta: { title: '商机' ,icon:iconRender('icon-dkw_tianxie'),permission:['busProject','busLoan','busDelay'] },
        children: [
          {
            path: '/business/List',
            name: 'business/List',
            component: () => import('@/views/business/List'),
            meta: { title: '项目' ,permission:['busProject']}
          },
          {
            path: '/business/addLoan',
            name: 'business/addLoan',
            component: () => import('@/views/business/AddLoan'),
            meta: { title: 'Top up (加贷)' ,permission:['busLoan']}
          },
          {
            path: '/business/delay',
            name: 'business/delay',
            component: () => import('@/views/business/Delay'),
            meta: { title: 'Extension (延期)' ,permission:['busDelay']}
          },
          {
            path: '/business/project/detail',
            name: 'business/detail',
            meta: { title: '项目详情' ,permission:['busProject']},
            hidden: true,
            component: () => import('@/views/business/project/Detail')
          },
        ]
      },
      // 项目评估
      {
        path: '/evaluation',
        name: 'evaluation',
        redirect: '/evaluation/project',
        component: RouteView,
        meta: { title: '项目评估',icon:iconRender('icon-dkw_ziliaoshenhe'),permission:['evalProject','evalLoan','evalDelay'] },
        children: [
          {
            path: '/evaluation/project',
            name: 'evaluation/project',
            component: () => import('@/views/evaluation/project/Project'),
            meta: { title: '项目'  ,permission:['evalProject'] }
          },
          {
            path: '/evaluation/addLoan',
            name: 'evaluation/addLoan',
            component: () => import('@/views/evaluation/AddLoan'),
            meta: { title: 'Top up (加贷)'  ,permission:['evalLoan'] }
          },
          {
            path: '/evaluation/delay',
            name: ' evaluation/delay',
            component: () => import('@/views/evaluation/Delay'),
            meta: { title: 'Extension (延期)'  ,permission:['evalDelay'] }
          },
          {
            path: '/evaluation/project/brief',
            name: 'evaluation/brief',
            meta: { title: '项目详情',permission:['evalProject'] },
            hidden: true,
            component: () => import('@/views/evaluation/project/Brief')
          },
          {
            path: '/evaluation/project/submitApply',
            name: 'evaluation/submitApply',
            hidden: true,
            component: () => import('@/views/evaluation/com/submitApply')
          },
        ]
      },
      //项目完成协议
      {
        path: '/agreement',
        name: 'agreement',
        meta: { title: '项目完成协议',icon:iconRender('icon-dkw_shenhetongguo') ,permission:['agreementList']},
        component: () => import('@/views/agreement/Agreement'),
      },
      {
        path: '/add',
        name: 'add',
        meta: { title: '加贷明细',permission:['agreementList']},
        hidden: true,
        component: () => import('@/views/agreement/Add'),
      },
      {
        path: '/delay',
        name: 'delay',
        meta: { title: '延期明细',permission:['agreementList']},
        hidden: true,
        component: () => import('@/views/agreement/Delay'),
      },
      {
        path: '/operation',
        name: 'operation',
        meta:{title:'日期设置'},
        hidden: true,
        component: () => import('@/views/agreement/Operation'),
      },
      //资金管理
      {
        path: '/manage',
        name: 'manage',
        redirect: '/manage/list',
        component: RouteView,
        meta: { title: '资金管理',icon:iconRender('icon-dkw_daikuan'),permission:['manageList','manageWithdraw','manageFund','manageWithdrawList','manageRepayment'] },
        children: [
          {
            path: '/manage/List',
            name: 'manage/list',
            meta: { title: '项目列表',permission:['manageList'] },
            component: () => import('@/views/manage/List'),
          },
          {
            path: '/manage/withdrawRequest/add',
            name: 'manage/withdrawRequest/add',
            meta: { title: '提款请求',permission:['manageWithdraw'] },
            hidden: true,
            component: () => import('@/views/manage/withdraw/addWithdraw')
          },
          {
            path: '/manage/withdrawRequest',
            name: 'manage/withdrawRequest',
            meta: { title: '提款请求',permission:['manageWithdraw'] },
            component: () => import('@/views/manage/withdraw/Withdraw')
          },
          {
            path: '/manage/withdrawFund',
            name: 'manage/withdrawFund',
            meta: { title: '提款资金安排',permission:['manageFund'] },
            component: () => import('@/views/manage/fund/fund')
          },
          {
            path: '/manage/withdrawFund/add',
            name: 'manage/withdrawFund/add',
            meta: { title: '提款安排' ,permission:['manageFund']},
            hidden: true,
            component: () => import('@/views/manage/fund/addFund')
          },
          {
            path: '/manage/withdrawList',
            name: 'manage/withdrawList',
            meta: { title: '提款列表',permission:['manageWithdrawList'] },
            component: () => import('@/views/manage/withdrawList')
          },
          {
            path: '/manage/repayment',
            name: 'manage/repayment',
            meta: { title: '还款',permission:['manageRepayment'] },
            component: () => import('@/views/manage/repayment/repayment')
          },
          {
            path: '/manage/repayment/add',
            name: 'manage/repayment/add',
            meta: { title: '新增还款',permission:['manageRepayment'] },
            hidden: true,
            component: () => import('@/views/manage/repayment/addRepay')
          },
          {
            path: '/manage/repayment/single',
            name: 'manage/repayment/single',
            meta: { title: '新增还款',permission:['manageRepayment'] },
            hidden: true,
            component: () => import('@/views/manage/repayment/reviseRepay')
          },
          {
            path: '/manage/detail',
            name: 'manage/detail',
            meta: { title: `项目细节`,permission:['manageList'] },
            hidden: true,
            component: () => import('@/views/manage/detail/project')
          },
        ]
      },
      //项目违约
      {
        path: '/default',
        name: 'default',
        redirect: '/default/calculation',
        component: RouteView,
        meta: { title: '项目违约' ,icon:iconRender('icon-dkw_mianxi'),permission:['defaultCalc','DefaultExe']},
        children: [
          {
            path: '/default/calculation',
            name: 'calculation',
            meta: { title: '违约计算',permission:['defaultCalc'] },
            component: () => import('@/views/default/calc/calculation'),
          },
          {
            path: '/default/calcOperation',
            name: 'calcOperation',
            meta: { title: '违约详情',permission:['defaultCalc'] },
            hidden:true,
            component: () => import('@/views/default/calc/calcOperation'),
          },
          {
            path: '/default/execute',
            name: 'execute',
            meta: { title: '违约执行',permission:['DefaultExe'] },
            component: () => import('@/views/default/execute/index'),
          },
          {
            path: '/default/execute/program',
            name: 'execute/program',
            meta: { title: '违约程序' ,permission:['DefaultExe']},
            hidden:true,
            component: () => import('@/views/default/execute/program'),
          },
          
        ]
      },
      //统计分析
      {
        path: '/statistical',
        name: 'statistical',
        redirect: '/dataAnalysis',
        component: RouteView,
        meta: { title: '统计分析' ,icon:iconRender('icon-shuju'),permission:['dataAnalysis']},
        children: [
          {
            path: '/dataAnalysis',
            name: 'dataAnalysis',
            meta: { title: '数据分析' ,permission:['dataAnalysis']},
            component:() => import('@/views/dashboard/Analysis'),
          },
          // {
          //   path: '/projectAnalysis',
          //   name: 'projectAnalysis',
          //   meta: { title: '项目分析' }
          // },
        ]
      },
      //系统管理
      {
        path: '/systemManage',
        name: 'systemManage',
        redirect: '/historyRate',
        component: RouteView,
        meta: { title: '系统管理' ,icon:iconRender('icon-rizhi'),permission:['sysManageRate','logManage'] },
        children: [
          {
            path: '/historyRate',
            name: 'historyRate',
            meta: { title: '历史汇率',permission:['sysManageRate'] },
            component: () => import('@/views/systemManage/historyRate'),
          },
          {
            path: '/logManage',
            name: 'logManage',
            meta: { title: '日志管理',permission:['logManage'] },
            component:()=>import('@/views/systemManage/logManage/index')
          },
        ]
      },
      //用户及权限
      {
        path: '/userPower',
        name: 'userPower',
        redirect: '/userList',
        component: RouteView,
        meta: { title: '用户及权限',icon:iconRender('icon-houtaiguanli-xitongguanliyuan') ,permission:['user','role'] },
        children: [
          {
            path: '/userList',
            name: 'userPower/userList',
            meta: { title: '用户列表' ,permission:['user'] },
            component:()=>import('@/views/userPower/user')
          },
          {
            path: '/addUser',
            name: 'userPower/addUser',
            meta: { title: '新增用户',permission:['user']  },
            hidden:true,
            component:()=>import('@/views/userPower/addUser')
          },
          {
            path: '/roleList',
            name: 'userPower/roleList',
            meta: { title: '角色列表' ,permission:['role'] },
            component:()=>import('@/views/userPower/role')
          },
          {
            path: '/addRole',
            name: 'userPower/addRole',
            meta: { title: '新增角色' ,permission:['role']},
            hidden:true,
            component:()=>import('@/views/userPower/addRole')
          },
        ]
      },
      // account
      {
        path: '/account',
        component: RouteView,
        redirect: '/account/center',
        name: 'account',
        hidden:true,
        meta: { title: 'menu.account', icon: 'user', keepAlive: true, },
        children: [
          {
            path: '/account/center',
            name: 'center',
            component: () => import('@/views/account/center'),
            
            meta: { title: 'menu.account.center', keepAlive: true, }
          },
          {
            path: '/account/settings',
            name: 'settings',
            component: () => import('@/views/account/settings/Index'),
            meta: { title: 'menu.account.settings', hideHeader: true, },
            redirect: '/account/settings/basic',
            hideChildrenInMenu: true,
            children: [
              {
                path: '/account/settings/basic',
                name: 'BasicSettings',
                component: () => import('@/views/account/settings/BasicSetting'),
                meta: { title: 'account.settings.menuMap.basic', hidden: true, }
              },
              {
                path: '/account/settings/security',
                name: 'SecuritySettings',
                component: () => import('@/views/account/settings/Security'),
                meta: {
                  title: 'account.settings.menuMap.security',
                  hidden: true,
                  keepAlive: true,
                
                }
              },
              {
                path: '/account/settings/custom',
                name: 'CustomSettings',
                component: () => import('@/views/account/settings/Custom'),
                meta: { title: 'account.settings.menuMap.custom', hidden: true, keepAlive: true, }
              },
              {
                path: '/account/settings/binding',
                name: 'BindingSettings',
                component: () => import('@/views/account/settings/Binding'),
                meta: { title: 'account.settings.menuMap.binding', hidden: true, keepAlive: true, }
              },
              {
                path: '/account/settings/notification',
                name: 'NotificationSettings',
                component: () => import('@/views/account/settings/Notification'),
                meta: {
                  title: 'account.settings.menuMap.notification',
                  hidden: true,
                  keepAlive: true,
                
                }
              }
            ]
          }
        ]
      }
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }
]
